package com.example.hp.serviceproject;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

public class BindService extends Service {
    private int info = 0;
    private Spy spy;
    public BindService() {
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i("kun","bind service create....");
        spy = new Spy();
        new Thread(){
            @Override
            public void run() {
                super.run();
                while (true){
                    try{
                        Thread.sleep(200);
                    }
                     catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    info++;
                    spy.setInfo(info);
                }

            }
        }.start();

    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.i("kun","bind service unbind....");
        return super.onUnbind(intent);


    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i("kun","bind service destroy...");
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.i("kun","onbind....");
        return spy;
    }
}
